package cn.dnui_zzh807.dnuifood_16110100807.controller;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.view.Menu;
import android.widget.Toast;

import cn.dnui_zzh807.dnuifood_16110100807.R;

public abstract class BaseActivity extends Activity {
    protected int layout_file= R.layout.activity_main;
    abstract void initViews();
    abstract void initEvents();
    abstract void initData();
    void setLayout(int layout_file)
    {
        setContentView(layout_file);
    }
    private Menu menu;

    public BaseActivity(){

    }

    public void setTitle(String name){
        //创建菜单
        getMenuInflater().inflate(R.menu.food_list_collect,menu);
        // this.menu=menu;
        //菜单创建完毕后向服务器发送请求，判断是否已经收藏
        //getCollectState();
        menu.findItem(R.id.item_collect1).setTitle(name);

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        //创建菜单
        getMenuInflater().inflate(R.menu.food_list_collect,menu);
        // this.menu=menu;
        //菜单创建完毕后向服务器发送请求，判断是否已经收藏
        //getCollectState();
        menu.findItem(R.id.item_collect1).setTitle("");

        return super.onCreateOptionsMenu(menu);
    }
    public String getUser_id(){
        SharedPreferences sp;
        sp=getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return sp.getString("user_id","");
    }

    public String getUser_password(){
        SharedPreferences sp;
        sp=getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return sp.getString("userpass","");
    }
    public void showToast(String content){

        Toast.makeText(this,content,Toast.LENGTH_LONG).show();
    }

}
